import ChartBase from './chart-base'
import {
  grid,
  legend,
  xAxis,
  yAxis,
  gridConfig,
  legendConfig,
  xAxisConfig,
  yAxisConfig,
  tooltip,
  tooltipConfig, lineSeries, lineSeriesLabel, lineSeriesConfig, lineSeriesLabelConfig
} from './common'

export default class LineBase extends ChartBase {
  constructor() {
    super()
  }

  // 基础描述
  _info = {
    name: '基础折线图',
    type: 'line-base',// 图表类型
    group: 'line',// 图表分类
    component: 'e-chart',
    icon: 'line-base'// 图表展示ICON
  }

  // 总 配置项
  _defaultOption = {
    dataset: {
      source: [],
      dimensions: []
    },
    grid,
    legend,
    tooltip,
    xAxis,
    yAxis,
    series: []
  }
  // 系列
  _defaultSeries = {
    type: 'line',
    ...lineSeries,
    label:lineSeriesLabel
  }

  // 数据结构描述
  _dataPoolConfig = [
    {
      label: '横轴',
      key: 'xField',
      type: ['string', 'date', 'number'],
      limit: 1
    },
    {
      label: '纵轴',
      key: 'yField',
      type: ['number'],
      limit: -1
    }
  ]

  // 样式配置描述信息
  _styleOptionConfig = [
    ...gridConfig,
    ...legendConfig,
    ...tooltipConfig,
    ...xAxisConfig,
    ...yAxisConfig,
    ...lineSeriesConfig,
    ...lineSeriesLabelConfig
  ]

  getClickData(event) {
    const { name, seriesName, value } = event

    return {
      label: name,
      value: value[seriesName]
    }
  }
}
